<template>
  <div>
    <van-nav-bar title="绑定信息" left-arrow @click-left="$router.push('/my')" />
    <div class="monerycard">
      <h3>身份证</h3>
      <div v-if="flag1" class="monerycardbg1">
        <p>姓名：{{ Datalist.name }}</p>
        <p>性别：{{ Datalist.sex }}</p>
        <p>身份证号：{{ Datalist.idNumber }}</p>
        <p>籍贯：{{ Datalist.nation }}</p>
      </div>
      <div v-else="!flag1" class="monerycardbg">
        <div class="monerytitle" @click="bindbank">绑定身份证>></div>
      </div>
    </div>
    <div class="idcard">
      <h3>银行卡</h3>
      <div v-if="flag" class="idcardbg1">
        <p>银行卡:{{ idData.bankCardNumber }}</p>
        <p>银行名称:{{ idData.bankName }}</p>
      </div>
      <div v-else="!flag" class="idcardbg">
        <div class="idtitle" @click="bindidcard">绑定银行卡>></div>
      </div>
    </div>

    <p class="bottitle">如需更改银行卡信息 请致电000-5967432</p>
  </div>
</template>
<script setup lang="ts">
import { findDoctorBankCardById, findDoctorIdCardInfo } from '../../api/wallet'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const doctorId = ref(parseInt(localStorage.getItem('doctorId') as string))
const sessionId = ref(JSON.parse(localStorage.getItem('sessionId') as string))
const idData:any = ref({})
const flag = ref(true)
const flag1 = ref(true)
const Datalist:any= ref({})
const router = useRouter()
const bindidcard = () => {
  router.push('/bindidcard')
}
const bindbank = () => {
  router.push('/bindcardbankcard')
}

//绑定身份证
const findDoctorIdCardInfo1 = async () => {
  const res = await findDoctorIdCardInfo(doctorId.value, sessionId.value)
  console.log('查看绑定身份证', res)
  if (res.data.status == '0000') {
    flag1.value = true
    Datalist.value = {
      idNumber: '4110110110110110',
      name: '张寒路111',
      sex: '男111',
      nation: '汉族111'
    }
  } else {
    flag1.value = false
  }
}
findDoctorIdCardInfo1()
//绑定银行卡
const findDoctorBankCardById1 = async () => {
  const res = await findDoctorBankCardById(doctorId.value, sessionId.value)
  console.log('查看绑定银行卡', res)
  if (res.data.status == '0000') {
    idData.value = res.data.result
    flag.value = true
  } else {
    flag.value = false
  }
}
findDoctorBankCardById1()
</script>
<style >
@import './bindcard.scss'
</style>